import React, { Component } from 'react';

class Login extends Component{
  constructor(props){
    super(props);
    this.state = {
      acount: '',
      pwd: ''
    }
  }
  login(e){
    e.preventDefault();
    localStorage.setItem('name',this.state.acount);
  }
  render(){
    return (
      <form className="form">
        <div className="form-group">
          <label htmlFor="">
            账号
            <input type="text" 
            className="form-control" 
            value={this.state.acount}
            onChange={(e)=>{this.setState({acount:e.target.value})}}/>
          </label>
        </div>
        <div className="form-group">
          <label htmlFor="">
            密码
            <input type="password" 
            className="form-control" 
            value={this.state.pwd}
            onChange={(e)=>{this.setState({pwd:e.target.value})}}/>
          </label>
        </div>
        <div className="form-group">
          <button 
          className="btn btn-default btn-primary"
          onClick={(e)=>{this.login(e)}}
          >登录</button>
        </div>
      </form>
    )
  }
}
export default Login;